home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / hard / hack / i2clib40.lha / i2clib40 / Install < prev    next >
Text File  |  1999-01-04  |  7KB  |  199 lines

  1.  
  2. (set @default-dest (expandpath "LIBS:"))
  3. (set #safedelay 10)
  4.  
  5. ;--------------------------- Englische Texte ----------------------------
  6.  
  7. (set #workmodeprompt (cat "This is a multi-purpose script. "
  8.         "What do you want to do?") )
  9. (set #workmode0 "Install i2c.library")
  10. (set #workmode1 "Configure")
  11. (set #workmode2 "Uninstall")
  12. (set #workmodehelp ( cat "\n\"Install\" copies a library to LIBS: and creates "
  13.         "an environment variable. Both can be removed again using the "
  14.         "\"Uninstall\" option.\n\n"
  15.         "\"Configure\" lets you adjust the environment variable which you "
  16.         "created during installation.") )
  17. (set #hwchoiceprompt "Pick your type of I²C interface:")
  18. (set #hwchoice0 "SERIAL PORT, as proposed by \"c't\" magazine")
  19. (set #hwchoice1 "serial port, Wiegand VTX 2000 hardware")
  20. (set #hwchoice2 "serial port, HSL VideoTXT hardware")
  21. (set #hwchoice3 "serial port, KDK Satcom PC-Videotext")
  22. (set #hwchoice4 "PARALLEL PORT, as proposed by Jan Leuverink")
  23. (set #hwchoice5 "parallel port, Printtechnik teletext")
  24. (set #hwchoice6 "parallel port, Microtext hardware")
  25. (set #hwchoice7 "autoconfig board, M&T TeleTxt")
  26. (set #hwchoice8 "FLOPPY PORT")
  27. (set #hwchoicehelp (cat "\nDepending on the kind of interface hardware you "
  28.         "own, you can have one of several customized i2c.library versions "
  29.         "installed. Those interfaces which are described in the accompanying "
  30.         "schematics are CAPITALIZED.") )
  31. (set #delayprompt "Enter a timing parameter for i2c.library:" )
  32. (set #delayhelp (cat "\nSetting too small a delay parameter will keep "
  33.         "i2c.library from working properly.\n\n"
  34.         "While a value of " #safedelay " should be safe for all systems (and "
  35.         "has apparently been confirmed to work for you, too), you might "
  36.         "want to try smaller values, to optimize throughput: "
  37.         "5 has often been reported to work for A1200, 1 for all other Amigas "
  38.         "(including A4000)." ) )
  39. (set #okmsg (cat "Communication with your I²C peripheral(s) was successfully "
  40.         "established. Congratulations.") )
  41. (set #advice (cat "\n\nHint: If you think that you chose the wrong type of "
  42.         "library, you might want to reset your Amiga before running this "
  43.         "script again. That's (in some cases) the only way to make sure that "
  44.         "the current i2c.library is removed from memory.") )
  45. (set #diagmsg5 (cat "I2CScan could not detect any listeners on your I²C bus. "
  46.         "This might of course be just because there aren't any?" #advice ) )
  47. (set #diagmsg10 (cat "I2CScan couldn't test your interface, because "
  48.         "i2c.library either failed to detect it, or failed to access it "
  49.         "(possibly due to resource conflicts)." #advice ) )
  50. (set #diagmsg15 (cat "I²C protocol errors occured while running I2CScan. "
  51.         "This might be because your hardware is not appropriate for the "
  52.         "type of i2c.library that you installed." #advice ) )
  53. (set #diagmsg20 "I2CScan failed to open i2c.library. This is weird." )
  54. (set #timingmsg (cat "Your I2CDELAY parameter does not seem to work for "
  55.         "i2c.library and has been reset to the default value of "
  56.         #safedelay ".") )
  57. (set #uifarewell (cat "Deinstallation complete!\n"
  58.         "i2c.library and the I2CDELAY environment variable have been "
  59.         "removed from your system.") )
  60.  
  61. ;---------------------------- Default values ----------------------------
  62.  
  63. (set #hwtype 0)         ; c't hardware
  64. (set #workmode 0)       ; normal installation
  65. (set #result 0)         ; will be overwritten once we run I2Cscan
  66. (set #farewell #okmsg)  ; this too, in case of an error
  67. (if (= 0 (exists "ENV:I2CDELAY"))
  68.   (run (cat "SetEnv I2CDELAY " #safedelay) )
  69. )
  70. (set #busdelay (getenv "I2CDELAY"))
  71.  
  72. ;-------------------- Experts may choose what to do. --------------------
  73.  
  74. (if (= @user-level 2)
  75.     (set #workmode
  76.         (askchoice
  77.             (prompt #workmodeprompt)
  78.             (help #workmodehelp)
  79.             (choices #workmode0 #workmode1 #workmode2)
  80.             (default #workmode)
  81.         )
  82.     )
  83. )
  84.  
  85. ;------------------------- Are we uninstalling? -------------------------
  86.  
  87. (if (= #workmode 2)
  88.   (
  89.     (delete "ENVARC:I2CDELAY")
  90.     (delete (tackon @default-dest "i2c.library") )
  91.     (run "Avail FLUSH >NIL:")
  92.     (message #uifarewell)
  93.     (exit (quiet))
  94.   )
  95. )
  96.  
  97. ;------ For normal installation, pick, install and test a library. ------
  98.  
  99. (if (= #workmode 0) (
  100.  
  101. (set #hwtype
  102.     (askchoice
  103.         (prompt #hwchoiceprompt)
  104.         (help #hwchoicehelp)
  105.         (choices #hwchoice0 #hwchoice1 #hwchoice2 #hwchoice3 #hwchoice4
  106.                  #hwchoice5 #hwchoice6 #hwchoice7 #hwchoice8 )
  107.         (default #hwtype)
  108.     )
  109. )
  110.  
  111. ; Copy the library binary.
  112. (set #sourcefile
  113.     (select #hwtype
  114.       "libs/i2c.library.ser"
  115.       "libs/i2c.library.ser2"
  116.       "libs/i2c.library.ser3"
  117.       "libs/i2c.library.ser4"
  118.       "libs/i2c.library.par"
  119.       "libs/i2c.library.par2"
  120.       "libs/i2c.library.par3"
  121.       "libs/i2c.library.card"
  122.       "libs/i2c.library.disk"
  123.     )
  124. )
  125. (copyfiles
  126.     (source #sourcefile)
  127.     (dest @default-dest)
  128.     (newname "i2c.library")
  129. )
  130.  
  131. ; Try to purge a currently loaded image.
  132. (run "Avail FLUSH >NIL:")
  133.  
  134. ; Before asking for an optimized delay value, does this library work at all?
  135. (set #result
  136.     (run (cat "bin/I2CScan -d" #safedelay " >NIL:") )
  137. )
  138. (if (= #result 20)
  139.     (set #farewell #diagmsg20)
  140. )
  141. (if (= #result 15)
  142.     (set #farewell #diagmsg15)
  143. )
  144. (if (= #result 10)
  145.     (set #farewell #diagmsg10)
  146. )
  147. (if (= #result 5)
  148.     (set #farewell #diagmsg5)
  149. )
  150.  
  151. ) ) ; #workmode 1
  152.  
  153. ;--------------------------- Interview, part 3 --------------------------
  154.  
  155. (if (= #result 0)           ; Alright, it works with the safe value. Optimize?
  156. (
  157.  
  158. (if (= @user-level 2)       ; this question for experts only
  159.     (set #busdelay
  160.         (asknumber
  161.             (prompt #delayprompt)
  162.             (help #delayhelp)
  163.             (range 0 100)
  164.             (default (+ #busdelay))
  165.         )
  166.     )
  167. )
  168.  
  169. ; Test the current setting of #busdelay
  170. (set #result
  171.     (run (cat "bin/I2CScan -d" #busdelay " >NIL:") )
  172. )
  173. (if (<> #result 0)          ; poorly chosen delay parameter
  174.     (
  175.     (set #farewell #timingmsg)
  176.     (set #busdelay #safedelay)
  177.     )
  178. )
  179.  
  180. )
  181. )   ; #result 0
  182.  
  183. ;-------------------------- Installation, part 2 ------------------------
  184.  
  185. ; create the I2CDELAY environment variable
  186. (run (cat "SetEnv I2CDELAY " #busdelay) )
  187. (copyfiles
  188.     (source "ENV:I2CDELAY")
  189.     (dest "ENVARC:")
  190. )
  191.  
  192. ;------------------------------- Farewell -------------------------------
  193.  
  194. (message #farewell)
  195.  
  196. (if (= #workmode 1)
  197.   (exit (quiet))
  198. )
  199.